package cn.iocoder.yudao.module.biz.framework.datapermission.config;

import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRuleCustomizer;
import cn.iocoder.yudao.module.biz.dal.dataobject.expand.record.ExpandRecordDO;
import cn.iocoder.yudao.module.biz.dal.dataobject.expand.targets.ExpandTargetViewDO;
import cn.iocoder.yudao.module.biz.dal.dataobject.expand.targets.channel.ExpandTargetChannelDO;
import cn.iocoder.yudao.module.biz.dal.dataobject.expand.targets.customer.ExpandTargetCustomerDO;
import cn.iocoder.yudao.module.biz.dal.dataobject.expand.targets.partner.ExpandTargetPartnerDO;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * biz包业务数据权限过滤规则配置
 */
@Configuration(proxyBeanMethods = false)
public class BizPermissionConfiguration {

    @Bean
    public DeptDataPermissionRuleCustomizer bizDeptDataPermissionRuleCustomizer() {
        return rule -> {
            // 拓展目标-客户
            rule.addUserColumn(ExpandTargetCustomerDO.class,"owner_user_id");
            rule.addDeptColumn(ExpandTargetCustomerDO.class, "dept_id");
            // 拓展目标-渠道
            rule.addUserColumn(ExpandTargetChannelDO.class,"owner_user_id");
            rule.addDeptColumn(ExpandTargetChannelDO.class, "dept_id");
            // 拓展目标-合作伙伴
            rule.addUserColumn(ExpandTargetPartnerDO.class,"owner_user_id");
            rule.addDeptColumn(ExpandTargetPartnerDO.class, "dept_id");

            // 拓展记录
            rule.addUserColumn(ExpandRecordDO.class,"owner_user_id");
            rule.addDeptColumn(ExpandRecordDO.class, "dept_id");

            // 拓展目标-视图
            rule.addUserColumn(ExpandTargetViewDO.class,"owner_user_id");
            rule.addDeptColumn(ExpandTargetViewDO.class, "dept_id");
        };
    }

}
